import { isEmpty, numberFormat } from "@/utils";

/**
 * 其他项目
 * 项目名称，建设单位，项目地点，立项批复投资额（合同总金额）
 */
export const otherColumns = [
  { label: "项目名称", prop: "name", className: "prj-name" },
  { label: "建设单位", prop: "project_dept_name", className: "dept-name" },
  { label: "项目地点", prop: "address" },
  {
    label: "立项批复投资总额(万元)",
    prop: "given_amount",
    formatVal: (val) => {
      if (isEmpty(val) || val === "0.00") {
        return "待定";
      }
      return val;
    },
  },
];

/**
 * 土地项目
 * 1、土地开发类项目列表中将设计概算额去掉，在项目阶段前加建设单位字段
 * 2、本版块项目展示顺序调整下，将“通州区潞城镇棚户区改造A-01地块土地开发项目”调到A-02上面，
 * 3、项目估算总投资未填写将立项批复填写，控制投资额未填写改成0
 */
export const tdColumns = [
  { label: "项目名称", prop: "name", className: "prj-name" },
  { label: "建设单位", prop: "project_dept_name", className: "dept-name" },
  { label: "项目阶段", prop: "stageLabel" },
  { label: "项目估算总投资(万元)", prop: "estimate_amount_or_given_amount" },
  { label: "立项批复投资总额(万元)", prop: "given_amount" },
  { label: "控制投资额(万元)", prop: "control_amount_or_given_amount" },
];

/**
 * 房建 | 市政基础设施
 */
export const szAndFjColumns = [
  { label: "项目名称", prop: "name", className: "prj-name" },
  { label: "项目阶段", prop: "stageLabel" },
  { label: "项目估算总投资(万元)", prop: "estimate_amount" },
  { label: "立项批复投资总额(万元)", prop: "given_amount" },
  { label: "设计概算额(万元)", prop: "design_amount" },
  { label: "控制投资额(万元)", prop: "control_amount_or_given_amount" },
];

export const colCfg = {
  SZJC: szAndFjColumns,
  FJ: szAndFjColumns,
  OTHER: otherColumns,
  TDKF: tdColumns,
};

// 土地   奥体中心区土地一级开发  隐藏

// 房建  估算排序

export const typeMoney = {
  SZJC: {
    lx: 2387822.981,
    wc: 1227751.561,
  },
  FJ: {
    lx: 10507426.4,
    wc: 6555179.979,
  },
  TDKF: {
    lx: 7726712.532,
    wc: 4903099.97,
  },
  OTHER: {
    lx: 41453,
    wc: 17639.139,
  },
};

export const countMoney = (types = []) => {
  let lx = 0;
  let wc = 0;
  Object.keys(typeMoney).forEach((k) => {
    if (types.includes(k)) {
      lx += typeMoney[k].lx;
      wc += typeMoney[k].wc;
    }
  });
  return {
    given_amount: lx,
    actual_amount: wc,
    complete_ratio: numberFormat((wc * 100) / lx, "0.00%"),
  };
};
